<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:fragment="pagination(pageNo,size,totalPages,url,params)">
<body>
<div class="modal-footer no-margin-top">
    <ul class="pagination pull-right no-margin">
        <!-- 首页 -->
        <li th:class="${pageNo == 1} ? 'disabled': ''">
            <a th:href="${pageNo == 1} ? 'javascript:void(0)' : ${url} + '?' + ${params} + '&pageSize=' + ${size}">首页</a>
        </li>
        <!-- 上一页 -->
        <li th:class="${pageNo == 1} ? 'disabled': ''">
            <a th:href="${pageNo == 1} ? 'javascript:void(0)' : ${url} + '?' + ${params} + '&pageNo=' +${pageNo - 1} + '&pageSize=' + ${size}"
               th:text="上一页"></a>
        </li>

        <!-- 总页码10页以内 -->
        <li th:if="${totalPages < 10}" th:class="${i == pageNo} ? 'active' : ''"
            th:each="i:${#numbers.sequence(1,totalPages)}">
            <a th:href="${pageNo == i} ? 'javascript:void(0)' : ${url} + '?' + ${params} + '&pageNo=' + ${i} + '&pageSize=' + ${size}"
               th:text="${i}"></a>
        </li>

        <!-- 总页码超出10页，且当前页面大于5页 第5页，且 大于 总页码 - 10 -->
        <li th:if="${totalPages >= 10 && pageNo > 5 && pageNo + 10 > totalPages}"
            th:class="${i == pageNo} ? 'active' : ''"
            th:each="i:${#numbers.sequence(totalPages - 10,totalPages)}">
            <a th:href="${pageNo == i} ? 'javascript:void(0)' : ${url} + '?' + ${params} + '&pageNo=' + ${i} + '&pageSize=' + ${size}"
               th:text="${i}"></a>
        </li>

        <!-- 总页码超出10页，且当前页面在 第6页，总页码 - 10 之间 -->
        <li th:if="${totalPages >= 10 && pageNo > 5 && pageNo + 10 <= totalPages}"
            th:class="${i == pageNo} ? 'active' : ''"
            th:each="i:${#numbers.sequence(pageNo - 4, pageNo + 5)}">
            <a th:href="${pageNo == i} ? 'javascript:void(0)' : ${url} + '?' + ${params} + '&pageNo=' + ${i} + '&pageSize=' + ${size}"
               th:text="${i}"></a>
        </li>

        <!-- 总页码超出10页，且当前页面在 第1页， 第5页 之间 -->
        <li th:if="${totalPages >= 10 && pageNo <= 5}"
            th:class="${i == pageNo} ? 'active' : ''"
            th:each="i:${#numbers.sequence(1,10)}">
            <a th:href="${pageNo == i} ? 'javascript:void(0)' : ${url} + '?' + ${params} + '&pageNo=' + ${i} + '&pageSize=' + ${size}"
               th:text="${i}"></a>
        </li>

        <!-- 下一页 -->
        <li th:class="${pageNo == totalPages} ? 'disabled': ''">
            <a th:href="${pageNo == totalPages} ? 'javascript:void(0)' : ${url} + '?' + ${params} + '&pageNo=' +${pageNo + 1} + '&pageSize=' + ${size}"
               th:text="下一页"></a>
        </li>
        <!-- 尾页 -->
        <li th:class="${pageNo == totalPages} ? 'disabled': ''">
            <a th:href="${pageNo == totalPages} ? 'javascript:void(0)' : ${url} + '?' + ${params} + '&pageNo=' +${totalPages} + '&pageSize=' + ${size}" th:text="尾页"></a>
        </li>
    </ul>

</div>
</body>